package com.hefei.blog.base.upload.consts;

import org.apache.log4j.Logger;

import com.hefei.blog.base.utils.PropertiesLoader;

public class FileConsts {
	private static Logger logger = Logger.getLogger(FileConsts.class);
	
	public static final String CONFIG = "/upload.properties";
	
	//Windows必填 图片处理工具GMagick的安装路径
	public static String gmHome = null;
	
	/**
	 * D:/workSoft/tomcat9/webapps/p
	 * 图片文件存储-头像目录 + /YYYY/MM/DD/
	 */
	public static String ROOT_PIC = null;
	
	/**
	 * D:/workSoft/tomcat9/webapps/file
	 * 用户上传的文件路径 + /YYYY/MM/DD/
	 */
	public static String ROOT_FILE = null;
	
	/**
	 * 用户文章静态化路径 + /YYYY/MM/DD/
	 * D:/workSoft/tomcat9/webapps/html
	 */
	public static String ROOT_HTML = null;
	
	
	
	/*
	 * 文件存储-临时文件目录
	 * 全路径 root + tempDir : D:/data/mblog/store/temp
	 */
	public static String tempDir = "/store/temp";
	
	/*
	 * 文件存储-原文件目录
	 */
	public static String origDir = "/store/orig";
	
	/*
	 * 文件存储-压缩目录
	 */
	public static String thumbsDir = "/store/thumbs";

	public static String screenshotDir = "/store/screenshot";
	
	
	// 图片文件允许格式
	public static String[] allowFilesPic = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" };
	
	/**
	 * 文件大小 单位M
	 */
	public static String UMEDITOR_FILE_SIZE_LIMIT = null;
	// 图片存储最大宽度
	public static int PIC_SCALE_MAX_WIDTH = 800;
	// 图片存储后缀
	public static String PIC_STORE_FILE_EXT = ".jpg";
	
	public static String PIC_IMAGE_PROCESSOR = "Thumbnailator";
	static{
		try {
			PropertiesLoader p = new PropertiesLoader(CONFIG);
			UMEDITOR_FILE_SIZE_LIMIT = p.getProperty("umeditor.fileSizeLimit");
			gmHome = p.getProperty("gmagick.home");
			ROOT_PIC = p.getProperty("store.root.pic");
			ROOT_HTML = p.getProperty("store.root.html");
			ROOT_FILE = p.getProperty("store.root.file");
			PIC_SCALE_MAX_WIDTH = p.getInteger("pic.scale.max.width");
			PIC_STORE_FILE_EXT = p.getProperty("pic.store.file.ext");
			PIC_IMAGE_PROCESSOR = p.getProperty("pic.image.processor");
		} catch (Exception e) {
			logger.error("上次文件、图片出现异常", e);
			System.exit(0);
		}
	}
}
